<?php
/*
Gets the html table to manage jobseeker resumes.
*/
function get_manage_jobseeker_resume_table($jobseekers,$controller)
{
	$CI =& get_instance();
	$table='<table id="example1" class="table table-bordered table-striped">';
	
	$headers = array('Seeker', 
	'Job Categories',
	'Preferred Locations:',
	'Action');
	
	
	$table.='<thead><tr>';
	foreach($headers as $header)
	{
		$table.="<th>$header</th>";
	}
	$table.='</tr></thead><tbody>';
	$table.=get_manage_jobseeker_resume_table_data_rows($jobseekers,$controller);
	$table.='</tbody>';
	$table.='<tfoot><tr>';
	foreach($headers as $header)
	{
		$table.="<th>$header</th>";
	}
	$table.='</tr></tfoot></table>';
	return $table;
}

/*
Gets the html data rows for the people.
*/
function get_manage_jobseeker_resume_table_data_rows($jobseekers,$controller)
{
	$CI =& get_instance();
	$table_data_rows='';
	
	foreach($jobseekers->result() as $jobseeker)
	{
		$table_data_rows.=get_manage_jobseeker_resume_data_row($jobseeker,$controller);
	}
	
	if($jobseekers->num_rows()==0)
	{
		$table_data_rows.="<tr><td >#</td><td>#</td><td>#</td><td>#</td></tr></tr>";
	}
	
	return $table_data_rows;
}

function get_manage_jobseeker_resume_data_row($jobseeker,$controller)
{
	$CI =& get_instance();
	$controller_name=strtolower(get_class($CI));
	//$width = $controller->get_form_width();
	
	$pre_categories="";
	$get_prefer_categories=$CI->model_globals->select_join_get_only_fields('job_preference_categories', $arr_fields = array('name'),$arr_join = array('job_sub_categories'=> array('using_job_sub_category_id' => 'job_sub_category_id')), $join_type = 'INNER', $arr_where = array('using_job_seeker_id'=>$jobseeker->job_seeker_id,'is_prefered'=>'YES'), $limit = NULL,$sort=NULL);
	$i=1;
	foreach($get_prefer_categories->result() as $category){
		$pre_categories.=$category->name;
		if($get_prefer_categories->num_rows()!=$i){
			$pre_categories.="<b> , </b>";
		}
		$i++;
	}
	
	$pre_locations="";
	$get_prefer_locations=$CI->model_globals->select_join_get_only_fields('job_preference_locations', $arr_fields = array('name'),$arr_join = array('job_locations'=> array('using_location_id' => 'job_location_id')), $join_type = 'INNER', $arr_where = array('using_job_seeker_id'=>$jobseeker->job_seeker_id,'is_prefered'=>'YES'), $limit = NULL,$sort=NULL);
	$j=1;
	foreach($get_prefer_locations->result() as $location){
		$pre_locations.=$location->name;
		if($get_prefer_locations->num_rows()!=$j){
			$pre_locations.="<b> , </b>";
		}
		$j++;
	}
	$table_data_row='<tr>';
	$table_data_row.='<td width="10%">'.$jobseeker->first_name.'.'.$jobseeker->last_name.'</td>';
	$table_data_row.='<td width="25%">'.character_limiter(($pre_categories==""?'None':$pre_categories),100).'</td>';		
	$table_data_row.='<td width="25%">'.character_limiter(($pre_locations==""?'None':$pre_locations),100).'</td>';		
	$table_data_row.='<td width="30%"><a class="btn  btn-info btn-sm jobseeker_register_id" title="View Detail" data-toggle="modal" data-target="#view-seeker-preference-modal" id="'.$jobseeker->job_seeker_id.'"><span class="glyphicon glyphicon-eye-open"></span> View Detail</a>
													<a class="btn  btn-primary btn-sm mail_jobseeker" title="Send Message" data-toggle="modal" data-target="#compose-message-modal" id="'.$jobseeker->job_seeker_id.'"><span class="glyphicon glyphicon-edit"></span> Message</a>
													<a href="'.base_url().'employers/download-jobseeker-resume/'.$jobseeker->job_seeker_id.'" class="btn btn-sm btn-warning"  title="View Resume"><span class="glyphicon glyphicon-file"></span> Resume</a></td>';		
	$table_data_row.='</tr>';
	
	return $table_data_row;
}
